package com.oig.sys.base.dto;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.oig.common.validator.GroupAdd;
import com.oig.common.validator.GroupEdit;
import io.swagger.v3.oas.annotations.media.Schema;

import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.math.BigDecimal;
import java.util.Date;

@Schema
@Data
public class CurrRateDto {

    @Schema(description = "id",requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotNull(message = "id必填", groups={GroupEdit.class})
    private Integer id;

    @Schema(description = "币种代码", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotEmpty(message = "参数错误,编码不能为空", groups={GroupAdd.class, GroupEdit.class})
    @Length(max = 3,min = 3, message = "参数错误,编码3位", groups={GroupAdd.class,GroupEdit.class})
    private String currency;

    @Schema(description = "对人民币汇率", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotNull(message = "对人民币汇率必填", groups={GroupAdd.class, GroupEdit.class})
    private BigDecimal rmbRate;

    @Schema(description = "对美元汇率")
    private BigDecimal usdRate;

    @Schema(description = "银行买入对人民币汇率")
    private BigDecimal bankRmbBrate;

    @Schema(description = "银行买入对美元汇率")
    private BigDecimal bankUsdBrate;

    @Schema(description = "银行卖出对人民币汇率")
    private BigDecimal bankRmbSrate;

    @Schema(description = "银行卖出对美元汇率")
    private BigDecimal bankUsdSrate;

    @Schema(description = "特殊价格")
    private BigDecimal bankRmbGiven;

    /**
     * 标识是否是海关汇率。0：不是，1：是
     */
    @Schema(description = "汇率类型，0：银行挂牌价，1：海关汇率", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @NotEmpty(message = "参数错误,汇率类型不能为空", groups={GroupAdd.class, GroupEdit.class})
    @Pattern(regexp = "[0|1]", message = "只能为0或1")
    private String customsFlag;

    @Schema(description = "汇率源")
    private String rateSource;

    @Schema(description = "汇率发布时间", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @NotNull(message = "汇率发布时间必填", groups={GroupAdd.class, GroupEdit.class})
    private Date rateTime ;

}
